package com.xinghanlaser.applet.base.common.exception;

import org.springframework.web.multipart.MultipartFile;

import java.io.File;

/**
 * @author shaodw
 * @description 文件异常类处理
 */
public abstract class Assert {
    public static void notNull(MultipartFile multipartFile) {
        if (multipartFile == null) {
            throw new BizException("文件不能为空");
        }
    }

    public static void fileExist(String path) {
        if (path == null) {
            throw new BizException("路径不能为空");
        }
        fileExist(new File(path));
    }

    public static void fileExist(File file) {
        if (!file.exists()) {
            throw new BizException(file + " 文件不存在");
        }
    }
}